/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DAO;

import DTO.UsuarioDTO;
import Hibernate.HibernateUtil;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author Freddy Feria
 */
public class UsuarioDAOImp implements UsuarioDAO{

    @Override
    public UsuarioDTO login(String usuario, String contrasena) {
        EntityManager entityManager = Persistence.createEntityManagerFactory("H2").createEntityManager();
        entityManager.getTransaction().begin();
        
        Criteria criteria = HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(UsuarioDTO.class).add(Restrictions.like("correo", usuario));
        for (Object object : criteria.list()) {
            System.out.println(object);
        }
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

}
